//
//  TableViewController.m
//  CoreImageDemo
//
//  Created by zero on 2017/6/12.
//  Copyright © 2017年 zero. All rights reserved.
//

#import "TableViewController.h"
#import "UseFilterViewController.h"
#import "UseMoreFilterViewController.h"
#import "CIDetector-Face.h"
#import "CIDetector-QRCode.h"

@interface TableViewController ()
@property (nonatomic,strong) NSArray* titleArray;
@end

@implementation TableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _titleArray = @[@"打印FilterName",
                    @"单滤镜效果",
                    @"多滤镜效果",
                    @"识别-人脸",
                    @"识别-二维码"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDatasoure

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _titleArray.count;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if(!cell){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = _titleArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        [self action_logFilterNamesByCategory];
    }else if(indexPath.row == 1){
        UseFilterViewController *VC = [[UseFilterViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if(indexPath.row == 2){
        UseMoreFilterViewController *VC = [[UseMoreFilterViewController alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.row == 3){
        CIDetector_Face* vc = [[CIDetector_Face alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 4){
        CIDetector_QRCode* vc = [[CIDetector_QRCode alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

#pragma mark - Public


#pragma mark - Private

- (void)action_logFilterNamesByCategory{
    NSArray* filters = [CIFilter filterNamesInCategory:kCICategoryDistortionEffect];
    for (NSString* filterName in filters) {
        NSLog(@"%@",filterName);
        CIFilter* filter = [CIFilter filterWithName:filterName];
        NSLog(@"filter attributes:@%@",[filter attributes]);
    }
}

#pragma mark - Getter


#pragma mark - Setter

@end
